import axios from "axios";

// create an axios instance
const service = axios.create({
  //   baseURL: process.env.VUE_APP_BASE_API,
  // baseURL: "https://www.violetsnow.link/sakura",
  baseURL: "http://101.35.6.207:8666/sakura/",
  // baseURL: "/api",
  timeout: 20000,
});

//请求拦截

//response 响应拦截
service.interceptors.response.use(
  (response) => {
    // el_Loading.close(); //请求成功，关闭加载效果
    const res = response.data;
    return Promise.resolve(res);
  },
  (error) => {
    // el_Loading.close();
    console.log("err" + error); // for debug
    switch (error.response.status) {
      case 401:
        // ...
        break;
      case 500:
        // ...
        break;
      default:
        return Promise.reject(error);
    }
  }
);

export default service;
